Navigation

More:





Impressum

Try Online

Try HAML-TO-PHP online

This data has been defined and can be used:

array (
  'title' => 'hello customer!',
  'text' => 'some content to be quoted <>',
)

For security reasons only two functions can be used in interpolations (PHP code):

HAML: (You can also copy paste samples from) Examples




Report missbehaviour:

HTML

Notice that selected=true magically turns into selected='selected'!

        <div><p> Hello customer
</p><p>SOME CONTENT TO BE QUOTED &lt;&gt;</p></div>You could be writing a letter here
<select><option value='r' >r</option><option value='g' selected='selected' >g</option></select>
        

rendered in your browser:

Hello customer

SOME CONTENT TO BE QUOTED <>

You could be writing a letter here

generated PHP code:

Note: Creating PHP functions is an option.

      function custom_haml(){
        ob_start();
        ob_implicit_flush(false);
        try{
        $args = func_get_args();
        /* put vars in scope:*/
        foreach ($args as $arr) { extract($arr); }
        ?>
        
<div>
<p> Hello customer

</p>
<p>
<?php echo htmlentities(strtoupper($text), ENT_QUOTES, 'utf-8')?>
</p>
</div>
<?php echo HamlUtilities::plain('utf-8','You could be writing a letter here'.'
')?>
<select>
<?php  foreach(array('r','g') as $c){?>
<option 
<?php echo HamlUtilities::renderAttribute('value',($c),'\'','utf-8',false)?> 
<?php echo HamlUtilities::renderAttribute('selected',($c=='g'),'\'','utf-8',false)?>>
<?php echo htmlentities($c, ENT_QUOTES, 'utf-8')?>
</option>
<?php }?>
</select>
        
<?php
        return ob_get_clean();
        }catch(Exception $e){
          // PHP does not have try finally - go Ruby!
          ob_end_clean();
          throw $e;
        }
      }
    

Questions? Contact Support

Next: usage sample